package com.sure.supermarketserver.sell.adjust.impl;

import com.sure.supermarketserver.common.Utils;
import com.sure.supermarketserver.sell.adjust.AdjustDto;
import com.sure.supermarketserver.sell.adjust.AdjustService;
import com.sure.supermarketserver.sell.adjust.dao.AdjustDao;
import com.sure.supermarketserver.stock.manage.GoodsDto;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: fyf
 * @Date: 2021/07/20/16:34
 * @Description:
 */
@Service
@Transactional
public class AdjustServiceImpl implements AdjustService {
    @Resource
    private AdjustDao adjustDao;

    @Override
    public Map<String, Object> goodsPage(AdjustDto dto) {
        Map<String, Object> page = new HashMap<>();
        try {
            page = Utils.getPage(dto, () -> adjustDao.adjustPage(dto));
        }catch (Exception e) {
            throw new RuntimeException("查询商品列表失败！", e);
        }
        return page;
    }

    @Override
    public void updGoods(AdjustDto dto) {
        try {
            adjustDao.updateAdjust(dto);
        }catch (Exception e) {
            throw new RuntimeException("修改商品信息失败！", e);
        }
    }
}
